import { PartialType } from '@nestjs/mapped-types';
import { IsNotEmpty, IsNumberString, IsOptional } from 'class-validator';

export class CreateAddressDto {
  @IsNotEmpty({ message: '收货人姓名不得为空' })
  name: string;

  @IsNotEmpty({ message: '收货人手机号不得为空' })
  @IsNumberString()
  phone: string;

  @IsNotEmpty({ message: '省市区地址不得为空' })
  address: string;

  @IsNotEmpty({ each: true, message: '省市区代码不得为空' })
  addressCode: string[];

  @IsNotEmpty({ message: '地址详情不得为空' })
  detailAdd: string;

  @IsOptional()
  isDefault?: boolean;
}

export class UpdateAddressDto extends PartialType(CreateAddressDto) {
  @IsNotEmpty({ message: 'id不能为空' })
  id: number;
}
